home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Files
/
Directory.cp
< prev
next >
Wrap
Text File
|
1997-06-28
|
1KB
|
65 lines
// Directory.cp
#ifndef Directory_h
#include "Directory.h"
#endif
#ifndef CatInfo_h
#include "CatInfo.h"
#endif
#ifndef NotADirectoryError_h
#include "NotADirectoryError.h"
#endif
#ifndef DirectoryNotFoundError_h
#include "DirectoryNotFoundError.h"
#endif
void Directory::Up()
{
Assert( !IsRoot() );
CatInfo info( *this );
id = info.Location().ParentID();
}
void Directory::Down( ConstPString name )
{
CatInfo info( *this, name );
if ( !info.IsDirectory() )
throw NotADirectoryError( noErr );
volume = info.Location().Volume();
id = info.Directory().ID();
}
Directory Directory::Parent() const
{
Assert( !IsRoot() );
CatInfo info( *this );
return info.Location().Parent();
}
Directory Directory::Find( VolumeID volume,
OSType folder,
bool creating )
{
int16 volumeFound;
int32 directoryFound;
OSErr error = FindFolder( volume.RefNum(),
folder,
creating,
&volumeFound,
&directoryFound );
switch ( error )
{
case fnfErr: throw DirectoryNotFoundError( error );
case dupFNErr: throw NotADirectoryError( error );
}
if ( error != noErr )
throw FileError( error );
return Directory( VolumeID::Make( volumeFound ),
DirectoryID::Make( directoryFound ) );
}